import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { getObject } from 'redux/modules/classes';
import { asyncConnect } from 'redux-async-connect';

@asyncConnect([{
  promise: ({ params: { className, objectId }, store: { dispatch } }) => {
    const promises = [];
    promises.push(dispatch(getObject(className, objectId)));
    return Promise.all(promises);
  }
}])

@connect(
  state => ({ item: state.classes.object }),
  dispatch => bindActionCreators({}, dispatch))

export default class ClassesItem extends Component {
  static propTypes = {
    item: PropTypes.object
  }
  render() {
    const { item } = this.props;
    return (
      <div className="container">
        <h1>ClassesItem-{item && item.objectId}</h1>
      </div>
    );
  }
}
